<!-- 决算:整体项目下单项工程列表查看- 单站页面-->
<template>
  <div>
    <!-- 基本信息 -->
    <jn-prj-detail :prj-id="prjId" :prj-type="prjType" />
    <!-- 项目站址信息 -->
    <jn-site-detail :prj-id="prjId" />
    <!-- 项目专属信息 -->
    <jn-proprietary-detail :prj-id="prjId" :prj-type="prjType" />
    <ActualTime ref="ActualTimeRef" :actual-time-list="actualTimeList" :url-list="urlList" :lc-list="lcList" />
    <!-- 计划进度时间表 -->
    <DesignScheduleTime ref="designScheduleTimeRef" :design-schedule-list="designScheduleList" :url-list="urlList" :lc-list="lcList" :basic-list="basicList" />
    <BeCompletedMessage v-if="this.showTitle" ref="beCompletedMessageRef" :basicList="basicList" :be-completed-message-list="beCompletedMessageList" :url-list="urlList" :lc-list="lcList" />
    <!-- 运营商订单信息 -->
    <OperatorMessage v-if="showOrderInfo" ref="operatorMessageRef" :operator-message-list="operatorMessageList" :url-list="urlList" :lc-list="lcList" />
    <!-- 结决算审核信息 -->
    <ReviewInformation ref="reviewInformationRef" :review-information-list="reviewInformationList" :url-list="urlList" :lc-list="lcList" :basic-list="basicList" />
    <!-- 工程档案信息 -->
    <EngineeringArchiveInformation ref="engineeringArchiveInformation" :engineering-archive-information-list="engineeringArchiveInformationList" :url-list="urlList" :lc-list="lcList" :prj-id="prjId" />
    <!-- 附件 -->
    <TCollapse title="附件">
      <iframe ref="myIframeFjRef" style="width:100%;" frameborder="0" scrolling="no" :src="fuJianSrc" />
    </TCollapse>
    <!-- 项目审批关闭信息 -->
    <!-- <jn-task-detail :process-inst-id="lcList.processInstID" /> -->
  </div>
</template>

<script>
import { getQueryObject } from '@/utils' // 获取url地址信息

import TCollapse from '@/components/basic/TCollapse.vue'
import SysConst from '@/common/const'
// import { getDropdownData } from '@/api/common' // 字典接口
import store from '@/store'

// 公共页面
import ActualTime from '@/views/actualBudget/communication/tFbusiness/actualTime'
import DesignScheduleTime from '@/views/actualBudget/communication/tFbusiness/designScheduleTime'
import BeCompletedMessage from '@/views/actualBudget/communication/tFbusiness/beCompletedMessage'
import EngineeringArchiveInformation from '@/views/actualBudget/communication/tFbusiness/engineeringArchiveInformation'
import OperatorMessage from '@/views/actualBudget/communication/tFbusiness/operatorMessage'
import ReviewInformation from '@/views/actualBudget/communication/tFbusiness/reviewInformation' // 查看单项工程
// import * as Common from '@/api/common'
import {
    getWFWorkItem,
    getActualScheduleNew,
    getScheduleNew,
    queryTFinInfoNew,
    getOperatorOrderInfoNew,
    getAuditInfoNew,
    getPrjDetail
} from '@/api/actualBudget/tFbusiness'
import { clonePage } from '@/utils'

// 展示信息
import JnPrjDetail from '@/components/jn/JnPrjDetail.vue'
import JnSiteDetail from '@/components/jn/JnSiteDetail.vue'
import JnProprietaryDetail from '@/components/jn/JnProprietaryDetail.vue'
// import JnTaskDetail from '@/components/jn/JnTaskDetail.vue'

export default {
    name: 'SingleProjectMessage',
    components: {
        TCollapse,
        ActualTime,
        DesignScheduleTime,
        BeCompletedMessage,
        EngineeringArchiveInformation,
        OperatorMessage,
        ReviewInformation,
        JnPrjDetail,
        JnSiteDetail,
        JnProprietaryDetail
        // JnTaskDetail
    },
    data() {
        return {
            junNanUrl: process.env.VUE_APP_JUNNAN_IFRAME_URL,
            fileUrl: process.env.VUE_APP_ZHONGRUAN_URL,
            spIframeSrc: '',
            fuJianSrc: '',
            basicList: {}, // 基本信息
            prjId: '',
            prjType: '',
            lcList: {},
            urlList: {},
            processInstId: '',
            btnConfig: 'B', // 默认传A .综合查询传B
            actualTimeList: {}, // 实际时间表数据
            designScheduleList: {}, // 计划进度时间表数据
            beCompletedMessageList: {}, // 竣工决算信息数据
            operatorMessageList: {}, // 运营商订单信息数据
            reviewInformationList: {}, // 结决算审核信息数据
            engineeringArchiveInformationList: {}, // 工程档案信息数据
            dicLists: {}, // 下拉框字典选项集合
            onNotShow: true, // 单站展示页面下拉框不可选
            // 分页信息
            pageParam: {
              pageSize: SysConst.PAGESIZE, // 每页显示val条
              pageNum: SysConst.CURRENT_PAGE, // 当前页
              total: SysConst.TOTAL // 总数
            }
        }
    },
    computed: {
        showTitle() {
          return (this.basicList.prjType !== 'Q' && !(['07', '25'].includes(this.basicList.buildModes))) && (+this.basicList.prjTab !== 1)
        },
        showOrderInfo() {
            if (+this.basicList.isNewbusiness === 2) {
                return false
            } else {
                return this.basicList.prjType !== 'Y' && +this.basicList.isNewbusiness !== 1
            }
      },
    },
    async created() {
        const { prjId, workItemId, processInstId, type } = getQueryObject()
        this.urlList = {
            prjId,
            workItemId,
            processInstId,
            type
          }
        if (this.urlList.workItemId) {
            const { data } = await getWFWorkItem({ workItemId: this.urlList.workItemId })
            this.lcList = data // 获取流程参数信息
            this.prjId = data.bizObject.prjId
        } else {
            this.prjId = this.urlList.prjId
            this.btnConfig = 'B'
        }
        await this.ifarmSrcPram()
        await this.presentDataFun()
        if (this.urlList.processInstId) {
            this.processInstId = this.urlList.processInstId
        }
        // 初始化判断 是否可操作
        if (this.urlList.type === 'done' || this.urlList.type === '1') {
            this.buttonDisable = []
            this.btnConfig = 'B'
        }
        store.commit('settings/setPageTitle', `${this.basicList?.prjName}`)
    },
    async mounted() {
        this.getList() // 获取基本信息
        // this.getDictData()
    },
    methods: {
        // 获取基本信息 专属信息 站址信息
        async getList() {
            window.addEventListener('message', (event) => {
                const base_url = ''
                if (event.origin === base_url) {
                    return
                }
                if (event.data.type === 'attachment') {
                    this.$refs.myIframeFjRef.style.height = event.data.height + 'px'
                    // console.log('附件高度')
                }
            })
        },
        // form展示信息获取,
        async presentDataFun() {
            // 实际时间表
            const getActualSchedule = await getActualScheduleNew({ prjId: this.prjId })
            if (getActualSchedule.code === '200') {
                this.actualTimeList = getActualSchedule.data
            }
            // 计划进度时间表
            const getSchedule = await getScheduleNew({ prjId: this.prjId })
            if (getSchedule.code === '200') {
                this.designScheduleList = getSchedule.data
            }
            // 竣工决算信息
            const queryTFinInfo = await queryTFinInfoNew({ prjId: this.prjId })
            if (queryTFinInfo.code === '200') {
                this.beCompletedMessageList = queryTFinInfo.data
                this.engineeringArchiveInformationList = queryTFinInfo.data
            }
            // 运营商订单信息
            const getOperatorOrderInfo = await getOperatorOrderInfoNew({ prjId: this.prjId, demandId: this.basicList.demandId })
            if (getOperatorOrderInfo.code === '200') {
                this.operatorMessageList = getOperatorOrderInfo.data
            }
            // 结决算审核信息
            const getAuditInfo = await getAuditInfoNew({ prjId: this.prjId })
            if (getAuditInfo.code === '200') {
                this.reviewInformationList = getAuditInfo.data
            }
        },
        // 获取下拉框数据
        // async getDictData() {
        //       const arr = ['PROJ_TYPE', 'BUILD_MODES']
        //       const promises = arr.map(item => getDropdownData(item))
        //       const results = await Promise.all(promises)
        //       arr.forEach((item, i) => {
        //           this.$set(this.dicLists, item, results[i].data ?? [])
        //       })
        //       this.$set(this.dicLists, 'FILE_UPLOAD_MODES', SysConst.UPLOAD_MODES)
        //   },
        // ifarm src 传参
        async ifarmSrcPram() {
            await getPrjDetail({ prjId: this.prjId }).then(res => {
                this.basicList = res.data // 获取基本信息
                this.prjType = this.basicList.prjType
            })

            var iframeParams = {
                prjType: this.basicList.prjType,
                nodeId: this.lcList.activityDefID, // activityDefID 流程节点ID
                buildModes: this.basicList.buildModes,
                orgId: this.basicList.orgId,
                towerType: '0',
                roomType: '0',
                prjId: this.basicList.prjId,
                projectId:this.prjId,
                prjStage: 'G',
                fileSupplierCode: '', // 供应商接口
                isChange: '0', // 默认传0
                operateType: '1', // 默认传1
                btnConfig: this.btnConfig// 默认传A .综合查询传B
            }

            // 附件信息
            if (this.urlList.type === 'done') {
              // 查看用的附件地址
              this.fuJianSrc = `${this.fileUrl}attachmentInfo?prjType=${iframeParams.prjType}&nodeId=${iframeParams.nodeId}&buildModes=${iframeParams.buildModes}&towerType=${iframeParams.towerType}&roomType=${iframeParams.roomType}&prjId=${iframeParams.prjId}&prjStage=${iframeParams.prjStage}&fileSupplierCode=${iframeParams.fileSupplierCode}&isChange=${iframeParams.isChange}&operateSystem=${iframeParams.operateSystem}&operateType=${iframeParams.operateType}&btnConfig=${iframeParams.btnConfig}&orgId=${iframeParams.orgId}&projectId=${iframeParams.projectId}`
            } else {
              // 待办操作用的附件地址
              this.fuJianSrc = `${this.fileUrl}attachmentInfoTodo?prjType=${iframeParams.prjType}&nodeId=${iframeParams.nodeId}&buildModes=${iframeParams.buildModes}&towerType=${iframeParams.towerType}&roomType=${iframeParams.roomType}&prjId=${iframeParams.prjId}&prjStage=${iframeParams.prjStage}&fileSupplierCode=${iframeParams.fileSupplierCode}&isChange=${iframeParams.isChange}&operateSystem=${iframeParams.operateSystem}&operateType=${iframeParams.operateType}&btnConfig=${iframeParams.btnConfig}&orgId=${iframeParams.orgId}&projectId=${iframeParams.projectId}`
            }
        },
        // 关闭
        handleClose() {
            clonePage()
        }
    }
}
</script>

<style lang="scss" scoped>
.el-collapse {
    margin-bottom: 15px;
}

.el-collapse-item {
    box-shadow: 0px 0px 6px 0px rgba(191, 192, 192, 0.52);
    /* 调整各个item之间的距离为20px */
    /* border: 1px; */
}

.el-collapse-item__wrap {
    padding: 0 20px;
    /* 为el-collapse-item的内容添加20像素的padding */
}

.el-collapse-item__header {
    padding-left: 20px;
    font-size: 14px;
    color: #333333;
    letter-spacing: 0;
    font-weight: 600;
}

.item_icon {
    width: 6px;
    background: rgb(235, 75, 75);
    height: 15px;
    margin-right: 10px;
    border-radius: 10px;
}

::v-deep .content-box {
    width: 100%;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 400;
    // line-height: 28px;
}
</style>
